<?php if (!defined('THINK_PATH')) exit();?> <!DOCTYPE html>
<html>
  
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>
      <?php echo $title; ?> - <?php echo C('TITLE'); ?>
    </title>
     <link rel="stylesheet" href="//at.alicdn.com/t/font_mqhl04idhqx8byb9.css">
      <link rel="stylesheet" href="/project/guangqiang/Public/layui/css/layui.css">
      <link rel="stylesheet" href="/project/guangqiang/Public/css/global.css">
       <script src="/project/guangqiang/Public/layui/layui.js">
        </script>
    <script src="/project/guangqiang/Public/js/jquery-3.2.1.min.js">
        </script>
  </head>
  
  <body>
    <div class="header">
      <div class="main">
        <a class="logo" href="<?php echo U('home/index/index');?>" title="Fly">
          仿Fly社区
        </a>
        <div class="nav">
          <a href="<?php echo U('Home/index/all');?>" class="<?php if(in_array(ACTION_NAME, ['all','unsolve','solve','wonder','myquestion']))echo 'nav-this' ?>">
            <i class="iconfont icon-wenda">
            </i>
            讨论
          </a>
          <a href="javascript:;">
            <i class="iconfont icon-iconmingxinganli" style="top: 2px;">
            </i>
            案例
          </a>
          <a href="javascript:;">
            <i class="iconfont icon-ui">
            </i>
            框架
          </a>
        </div>
          <?php if($_SESSION['uid']){ ?>
           <div class="nav-user">
	         <a class="avatar" href="<?php echo U('Home/userCenter/set');?>">
	           <img src='/project/guangqiang/<?php echo $_SESSION['face'] ?>'>
	           <cite>
	             <?php echo $_SESSION['nickname'] ?>
	           </cite>
	         </a>
           <?php if($_SESSION['msg']!=0 && $_SESSION['msg']<=99){ ?>
              <a class="nav-message" href="<?php echo U('home/userCenter/delMsg',['del'=>1]);?>" title="您有<?php echo $_SESSION['msg']; ?>条未阅读的消息"><?php echo $_SESSION['msg']; ?></a>
            <?php }elseif($_SESSION['msg']>99){ ?>
              <a class="nav-message" href="<?php echo U('home/userCenter/delMsg',['del'=>1]);?>" title="您有99+条未阅读的消息"><?php echo '99+'; ?></a>
            <?php } ?>
	         <div class="nav">
	           <a href="<?php echo U('home/userCenter/set');?>">
	             <i class="iconfont icon-shezhi">
	             </i>
	             设置
	           </a>
	           <a href="<?php echo U('home/logOut/index');?>">
	             <i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;">
	             </i>
	             退了
	           </a>
	         </div>
		     </div>
          	<?php }else{ ?>
				<div class="nav-user">
		          <a class="unlogin" href="/user/login/">
		            <i class="iconfont icon-touxiang">
		            </i>
		          </a>
		          <span>
		            <a href="<?php echo U('home/login/index');?>">
		              登入
		            </a>
		            <a href="<?php echo U('home/reg/index');?>">
		              注册
		            </a>
		          </span>
		          <p class="out-login">
		            <a href="http://fly.layui.com/app/qq" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})"
		            class="iconfont icon-qq" title="QQ登入">
		            </a>
		            <a href="http://fly.layui.com/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})"
		            class="iconfont icon-weibo" title="微博登入">
		            </a>
		          </p>
          </div>
          	<?php } ?>
         
      </div>
    </div>



<style type="text/css">
.page{
  margin: 20px 0;
}
.page a{
  border: 1px solid #009E94;
  padding: 10px 20px;
  margin: 0 2px;
}
.current{
  background: #009E94;
  color: #fff;
  padding: 10px 20px;
  margin: 0 2px;
  border: 1px solid #009E94;
}
.page{
  margin-top: 30px;
}

</style>
<div class="main layui-clear">
<div class="wrap">
  <div class="content detail">
    <div class="fly-panel detail-box">
      <h1>
        <?php echo $msg['title']; ?>
      </h1>
      <div class="fly-tip fly-detail-hint">
        <?php if($msg['level']==2){ ?>
          <span class="fly-tip-stick">置顶帖</span>
        <?php }elseif($msg['level']==1){ ?>
          <span class="fly-tip-jing">精帖</span>
        <?php  } ?>
        <span>
        <?php echo $msg['status']; ?>
        </span>
        <div class="jie-admin-box" data-id="12154">
        </div>
        <div class="fly-list-hint">
          <a href="#comment">
            <i class="iconfont" title="回答">
              &#xe60c;
            </i>
            <?php echo $msg['answer_num']; ?>
          </a>
          <i class="iconfont" title="人气">
            &#xe60b;
          </i>
          <?php echo $msg['view_num']; ?>
        </div>
      </div>
      <div class="detail-about">
        <a class="jie-user" href="<?php echo U('home/userCenter/center',array('id'=>$msg['uid'])); ?>">
          <img src="/project/guangqiang/<?php echo $msg['face']; ?>">
          <cite>
            <?php echo $msg['nickname']; ?>
            <em>
              <?php echo Ctime($msg['create_time']); ?>
            </em>
          </cite>
        </a>
        <div class="detail-hits" id="LAY_jieAdmin" data-id="12154">
          <span style="color:#FF7200">
            悬赏：<?php echo $msg['kiss']; ?>飞吻
          </span>
          <?php if($msg['uid']==$_SESSION['uid'] && $msg['status']=='未结贴'): ?>
            <span class="layui-btn layui-btn-mini jie-admin edit" type="edit"><a href="<?php echo U('home/publish/index',array('qid'=>$msg['qid']));?>">编辑此贴</a></span>
          <?php endif; ?>
          <?php if(isset($_SESSION['uid'])): ?>
            <?php if(!$col){ ?>
            <span class="layui-btn layui-btn-mini jie-admin collect" type="collect" data-type="add">收藏
            <input type="hidden" class='qid' name="qid" value="<?php echo $msg['qid']; ?>"></span>
            <span class="layui-btn layui-btn-mini jie-admin  layui-btn-danger collect" type="decollect" data-type="add" style="display:none;"><input type="hidden" class='qid' name="qid" value="<?php echo $msg['qid']; ?>">取消收藏</span>
            <?php }else{ ?>
            <span class="layui-btn layui-btn-mini jie-admin collect" type="collect" data-type="add" style="display:none;">收藏
            <input type="hidden" class='qid' name="qid" value="<?php echo $msg['qid']; ?>"></span>
            <span class="layui-btn layui-btn-mini jie-admin  layui-btn-danger collect" type="decollect" data-type="add"><input type="hidden" class='qid' name="qid" value="<?php echo $msg['qid']; ?>">取消收藏</span>
            <?php  } ?>
          <?php endif; ?>
        </div>
      </div>
      <div class="detail-body photos">
        <?php echo htmlspecialchars_decode($msg['content']); ?>
      </div>
    </div>
    <div class="fly-panel fly-hezuo" time-limit="2017.07.27-2018.08.28">
      <a href="http://q.jinsom.cn" target="_blank" rel="nofollow">
        <img src="http://q.jinsom.cn/lightsns.png" >
      </a>
    </div>
    <div class="fly-panel detail-box" style="padding-top: 0;">
        <ul class="jieda photos" id="jieda">
        <?php if(empty($pages)){ ?>
          <li class="fly-none">没有任何回答</li>
        <?php  }else{ ?>
        <?php foreach ($pages as $a) : ?>
        <li data-id="42122">
          <a name="item-1501574372603">
          </a>
          <div class="detail-about detail-about-reply">
            <a class="jie-user" href="/u/5114424/">
              <img src="/project/guangqiang/<?php echo $a['face']; ?>"
              alt="<?php echo $a['nickname']; ?>">
              <cite>
                <i>
                  <?php echo $a['nickname']; ?>
                </i>
              </cite>
            </a>
            <div class="detail-hits">
              <span>
                <?php echo Ctime($a['create_time']); ?>
              </span>
            </div>
            <?php if($a['status']==1): ?>
              <i class="iconfont icon-caina" title="最佳答案"></i>
            <?php endif; ?>
          </div>
          <div class="detail-body jieda-body">
            <?php echo htmlspecialchars_decode($a['content']) ?>
          </div>
          <div class="jieda-reply">
            <span class="jieda-zan <?php  if($a['is_zan']==1){ ?>
             zanok
            <?php }; ?>" type="zan">
              <i class="iconfont icon-zan">
                <input type="hidden" class='aid' name="aid" value="<?php echo $a['aid']; ?>">
              </i>
              <em>
                <?php echo $a['zan_num']; ?>
              </em>
            </span>
            <span type="reply" class='reply'>
              <input type="hidden" class='nickname' value="<?php echo $a['nickname']; ?>">
              <i class="iconfont icon-svgmoban53">
              </i>
              回复
            </span>
            <?php if($_SESSION['uid']==$msg['uid'] && $msg['status']=='未结贴'): ?>
              <!-- <a class='adopt' href="<?php echo U('home/discuss/adopt',array('aid'=>$a['aid'],'qid'=>$a['qid']));?>"> -->
               <span type="reply" class='adopt'>采纳
                  <input type="hidden" class='aid' name='aid' value="<?php echo $a['aid']; ?>">
                  <input type="hidden" class='qid' name='qid' value="<?php echo $a['qid']; ?>">
               </span>
              <!-- </a> -->
            <?php endif; ?>
          </div>
        </li>
        <?php endforeach; ?>
        <?php  } ?>
      </ul>
      <div class="page">
        <?php echo $page; ?>
      </div>
      <div class="layui-form-pane">
        <form  class="layui-form" method="post">
          <div class="layui-form-item layui-form-text">
            <a name="comment">
            </a>
            <div class="layui-input-block">
              <textarea id="L_content" name="content" required  placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;">
              </textarea>
               
            </div>
          </div>
          <div class="layui-form-item">
            <input type="hidden" id='qq' name="qid" value="<?php echo $_GET['qid'];?>">
            <input type="hidden" name="jid" value="12154">
            <button class="layui-btn" lay-filter="sub" lay-submit>
              提交回答
            </button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<div class="edge">
  <dl class="fly-panel fly-list-one">
    <dt class="fly-panel-title">
      近期热议
    </dt>
    <?php foreach ($rows as $row):?>
      <dd>
      <a href="<?php echo U('home/discuss/index').'?qid='.$row['qid'] ?>">
        <?php echo $row['title']; ?>
      </a>
      <span>
        <i class="iconfont">
          &#xe60c;
        </i>
        <?php echo $row['answer_num']; ?>
      </span>
    </dd>
    <?php endforeach; ?>
  </dl>
  <div class="fly-panel fly-hezuo" style="height: 166px;" time-limit="2017.07.17-2018.07.18">
    <a href="http://www.fineui.com/" target="_blank" rel="nofollow">
      <img src="/project/guangqiang/Public/images/168_1500288431734_18970.jpg" style="width: 336px;">
    </a>
  </div>
  <div class="fly-panel">
    <a href="http://layim.layui.com/?from=fly" target="_blank">
      <img src="/project/guangqiang/Public/images/168_1500291753257_18702.jpg" style="width: 336px; height: 166px;"
      alt="layim下载">
    </a>
  </div>
  <a href="mailto:xu@sentsin.com">
    <div class="fly-panel fly-hezuo" style="height: 90px; background-color: #F9F9F9;"
    time-limit="">
    </div>
  </a>
</div>
</div>
<script type="text/javascript">
  function getPar(par){
    //获取当前URL
    var local_url = document.location.href; 
    //获取要取得的get参数位置
    var get = local_url.indexOf(par +"=");
    if(get == -1){
        return false;   
    }   
    //截取字符串
    var get_par = local_url.slice(par.length + get + 1);    
    //判断截取后的字符串是否还有其他get参数
    var nextPar = get_par.indexOf("&");
    if(nextPar != -1){
        get_par = get_par.slice(0, nextPar);
    }
    return get_par;
}
  //$('#qq').val(getPar('qid'));
  //alert($('#qq').val());
  
</script>
<script type="text/javascript">
  $('.adopt').click(function (){
      that=$(this);
      $.ajax({
        url: '<?php echo U("home/discuss/adopt");?>',
        type: 'POST',
        dataType: 'json',
        data: {aid:that.children('.aid').val(),qid:that.children('.qid').val()}
      })
      .done(function(respones) {
        if(respones.error==0){
          location.reload();
        }
      })
      .fail(function() {
        console.log("error");
      })
  });
  $('.jieda-zan').click(function(){
     that=$(this);
     //alert(that.children('i').children('.zan').val());
     //return false;
     $.ajax({
       url: '<?php echo U("home/discuss/zan");?>',
       type: 'POST',
       dataType: 'json',
       data: {aid:that.children('i').children('.aid').val()}
     })
     .done(function(respones) {
       if(respones.error==2){
          //alert(parseInt(that.children('em').html())+1);
          that.children('em').html(parseInt(that.children('em').html())+1);
          that.addClass('zanok');
       }else if(respones.error==0){
          //alert(parseInt(that.children('em').html())-1);
          that.children('em').html(parseInt(that.children('em').html())-1);
          that.removeClass('zanok');
       }else{
          layer.alert('请先登录',{icon:6},function (){
              location.href='<?php echo U("home/login/index");?>';
          });
       }
     })
     .fail(function() {
       console.log("error");
     })
  })
  $('.collect').click(function(){
     that=$(this);
     //alert(that.children('i').children('.zan').val());
     //return false;
     $.ajax({
       url: '<?php echo U("home/discuss/collect");?>',
       type: 'POST',
       dataType: 'json',
       data: {qid:that.children('.qid').val()}
     })
     .done(function(respones) {
       if(respones.error==0){
          that.hide();
          that.siblings('.collect').show();
       }else{
          that.hide();
          that.siblings('.collect').show();
       }
     })
     .fail(function() {
       console.log("error");
     })
  })
  layui.use(['layer', 'form','layedit'], function(){
      var layer = layui.layer,form = layui.form(),layedit = layui.layedit;
      layedit.set({
        uploadImage: {
          url: '<?php echo U("home/discuss/comment");?>' //接口url
          ,type: '' //默认post
        }
      });
      index = layedit.build('L_content');
       form.verify({
          content: function(value){
            if(value.length < 10){
              return '内容至少得10个字符啊';
            }
          }
        })
      form.on('submit(sub)', function(data){
       data.field.content=layedit.getContent(index);
        $.ajax({
        url:'<?php echo U("home/discuss/getcontent");?>',
          type: 'POST',
          dataType: 'json',
          data: data.field,
        })
        .done(function(respones) {
          if(respones.error==1){
               layer.alert('请先登录',{icon:6},function (){
                    location.href='<?php echo U("home/login/index");?>';
                });
          }else{
                layer.alert('评论成功',{icon:6},function (){
                    location.reload();
                });
          }
        })
        .fail(function() {
          console.log("error");
        });

        return false;
       });

      $('.reply').click(function(event) {
        data = '@'+$(this).children('.nickname').val();
        layedit.setContent(index,data);

      });
    });
  </script> 

</div>
    <div class="footer">
      <p>
        <a href="http://fly.layui.com/">
          Fly社区
        </a>
        2017 &copy;
        <a href="http://www.layui.com/">
          layui.com
        </a>
      </p>
      <p>
        <a href="http://fly.layui.com/jie/3147.html" target="_blank">
          产品授权
        </a>
        <a href="http://fly.layui.com/jie/8157.html" target="_blank">
          获取Fly社区模版
        </a>
        <a href="http://fly.layui.com/jie/2461.html" target="_blank">
          微信公众号
        </a>
      </p>
    </div>

    
  </body>
	<script type="text/javascript">
		layui.use(['layer', 'form','element'], function(){
		  var layer = layui.layer
		  ,form = layui.form();
		   $ = layui.jquery;
		  /*form.on('submit(login)', function(data){
				$.ajax({
				url:'<?php echo U("home/login/checkdata");?>',
					type: 'POST',
					dataType: 'json',
					data: data.field,
				})
				.done(function(respones) {
					if(respones.error==1){
                        layer.msg(respones.info,function (){

                     })
					}else{
                        layer.alert('登录成功',{icon:6},function (){
                            location.href='<?php echo U("home/user/index");?>';
                        });
                    }
				})
				.fail(function() {
					console.log("error");
				});

				return false;
		   });*/
		 
		
		});
	</script>
</html>